﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ERP_UseManage.aspx.cs" Inherits="CRM_Manager_ERP_UseManage" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>商品用途维护</title>
 <link href="../css/PageStyle.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="../JavaScript/Common.js"></script>

    <script type="text/javascript" src="../JavaScript/JS_Media.js"></script>

    <script type="text/javascript">
        function nodeLoad(node) {
            Ext.net.DirectMethods.NodeLoad(node.id, {
                success: function(result) {
                    var data = eval("(" + result + ")");
                    node.removeAll();
                    node.loadNodes(data);
                },
                failure: function(errorMsg) {
                    Ext.Msg.alert('Failure', errorMsg);
                }
            });
        }
        function nodeClick(node) {
            Ext.net.DirectMethods.NodeClick(node.id);
        }
        function nodedragover(e) {
            var node = e.target;
            if (node.leaf)
                node.leaf = false;
            return true;
        }
        var moveNode = function(tree, node, oldParent, newParent, index) {
            Ext.net.DirectMethods.MoveNode(node.id, newParent.id, {
                success: function(result) {
                    if (result) {
                        Ext.Msg.alert('系统提示', '保存失败|' + result);
                        return false;
                    }
                }
            });
        }
        function FieldEmptyCheck() {
            if (exttxtf_Use_NAME.getValue() == "") {
                Ext.Msg.alert('系统提示', '用途名称不能为空！');
                return false;
            }
            return true;
        }
        function ClostWin() {
            popWindow.hide();
        }
        function Add_Click() {
            var node = TreePanel1.getSelectionModel().getSelectedNode();
            extHid_coboDeptId.setValue(node.id);
            exttxtf_parent_id.setValue(node.text);
            exttxtf_remark.setValue("");
            exttxtf_Use_NAME.setValue("");
            extHid_Obj_ID.setValue("Add");
            popWindow.show();
        }
        function Edit_Click() {
            if (!GridPanel1.hasSelection()) {
                Ext.Msg.alert("系统提示", "请选择记录!");
                return;
            }
            var record = GridPanel1.selModel.getSelected();
            var Obj_ID = record.data.Use_ID;
            extHid_Obj_ID.setValue(Obj_ID);

            Ext.net.DirectMethods.ShowData(Obj_ID, {
                success: function(result) {
                    if (result)
                        Ext.Msg.alert('系统提示', '保存失败|' + result);
                    else
                        popWindow.show();
                },
                failure: function(errorMsg) {
                    Ext.Msg.alert('系统提示', '保存失败|' + errorMsg);
                }
            });
        }
        function SaveWin() {
            if (FieldEmptyCheck() == false)
                return false;
            Ext.net.DirectMethods.SaveData(extHid_Obj_ID.getValue(), {
                success: function(result) {
                    if (result)
                        Ext.Msg.alert('系统提示', '保存失败|' + result);
                    else {
                        var node = TreePanel1.getSelectionModel().getSelectedNode();
                        nodeLoad(node);
                        popWindow.hide();
                    }
                },
                failure: function(errorMsg) {
                    Ext.Msg.alert('系统提示', '保存失败|' + errorMsg);
                }
            });
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" AjaxViewStateMode="Enabled" />
    <ext:Store ID="Store1" runat="server" AutoLoad="false" OnRefreshData="OnStoreRefreshData">
        <Reader>
            <ext:JsonReader IDProperty="Use_ID">
                <Fields>
                    <ext:RecordField Name="Use_ID" />
                    <ext:RecordField Name="INNER_NO" />
                    <ext:RecordField Name="Use_NAME" />
                    <ext:RecordField Name="PARENT_ID" />
                    <ext:RecordField Name="REMARK" />
                    <ext:RecordField Name="DEL_FLAG" />
                    <ext:RecordField Name="Use_PYM" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server">
        <Items>
            <ext:ColumnLayout ID="ColumnLayout1" runat="server" Split="false" FitHeight="true">
                <Columns>
                    <ext:LayoutColumn ColumnWidth="0.25">
                        <ext:Panel ID="Panel1" runat="server" Border="false">
                            <Items>
                                <ext:FitLayout ID="FitLayout1" runat="server">
                                    <Items>
                                        <ext:TreePanel ID="TreePanel1" runat="server" Border="false" UseArrows="true" AutoScroll="true"
                                            Animate="true" EnableDD="true" ContainerScroll="true">
                                            <Listeners>
                                                <BeforeLoad Fn="nodeLoad" />
                                                <Click Fn="nodeClick" />
                                                <MoveNode Fn="moveNode" />
                                                <NodeDragOver Fn="nodedragover" />
                                            </Listeners>
                                            <TopBar>
                                                <ext:Toolbar ID="Toolbar2" runat="server" Height="26">
                                                    <Items>
                                                        <ext:ToolbarTextItem Text="商品用途分类" Height="40" />
                                                        <ext:ToolbarFill ID="ToolbarFill2" runat="server" />
                                                    </Items>
                                                </ext:Toolbar>
                                            </TopBar>
                                        </ext:TreePanel>
                                    </Items>
                                </ext:FitLayout>
                            </Items>
                        </ext:Panel>
                    </ext:LayoutColumn>
                    <ext:LayoutColumn ColumnWidth="0.75">
                        <ext:Panel ID="Panel2" runat="server" BodyStyle="border-width:0 0 0 1px;">
                            <Items>
                                <ext:Toolbar ID="Toolbar1" runat="server">
                                    <Items>
                                        <ext:Button ID="extBtn_Refresh" runat="server" Text="刷新" Icon="ArrowRefresh">
                                            <DirectEvents>
                                                <Click OnEvent="extBtn_Refresh_Click">
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                        <ext:Button ID="extBtn_Add" runat="server" Text="新增" Icon="Add">
                                            <Listeners>
                                                <Click Fn="Add_Click" />
                                            </Listeners>
                                        </ext:Button>
                                        <ext:Button ID="extBtn_Edit" runat="server" Text="修改" Icon="GroupEdit">
                                            <Listeners>
                                                <Click Fn="Edit_Click" />
                                            </Listeners>
                                        </ext:Button>
                                        <ext:Button ID="extBtn_Del" runat="server" Text="删除" Icon="Delete">
                                            <DirectEvents>
                                                <Click OnEvent="DelUser">
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                        <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                                        <ext:TextField runat="server" ID="exttxtf_user_name" EmptyText="依名称查询...">
                                        </ext:TextField>
                                        <ext:Button ID="extBtn_Find" runat="server" Text="查询">
                                            <DirectEvents>
                                                <Click OnEvent="extBtn_Find_Click">
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                    </Items>
                                </ext:Toolbar>
                                <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" Border="false" AutoHeight="true"
                                    AutoWidth="true" AutoExpandColumn="REMARK">
                                    <ColumnModel ID="ColumnModel1" runat="server">
                                        <Columns>
                                            <ext:RowNumbererColumn Header="序号" Width="35" />
                                            <ext:Column Header="<center>商品用途编码</center>" Width="100" Sortable="true" DataIndex="INNER_NO"
                                                Groupable="True" Fixed="True" Hidden="true">
                                            </ext:Column>
                                            <ext:Column Header="<center>商品用途名称</center>" Width="100" Sortable="true" DataIndex="Use_NAME">
                                            </ext:Column>
                                            <ext:Column Header="<center>备注</center>" Sortable="true" DataIndex="REMARK">
                                            </ext:Column>
                                        </Columns>
                                    </ColumnModel>
                                    <SelectionModel>
                                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server">
                                        </ext:RowSelectionModel>
                                    </SelectionModel>
                                    <Listeners>
                                        <DblClick Handler=" Edit_Click();" />
                                    </Listeners>
                                    <LoadMask />
                                </ext:GridPanel>
                            </Items>
                        </ext:Panel>
                    </ext:LayoutColumn>
                </Columns>
            </ext:ColumnLayout>
        </Items>
    </ext:Viewport>
    <ext:Window ID="popWindow" runat="server" Icon="Group" Width="450" Height="230" AutoShow="false"
        Modal="true" Hidden="true" Closable="true" Resizable="true" Draggable="true"
        Title="商品用途信息">
        <Content>
            <ext:Panel ID="Panel6" runat="server" Border="false" Height="190" BodyStyle="border-width:0 0 0 0;padding:6 5 6 5;"
                ButtonAlign="Center">
                <TopBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button ID="btnSave" runat="server" Text="确定" Icon="Disk">
                                <Listeners>
                                    <Click Fn="SaveWin" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="btnCancel" runat="server" Text="关闭" Icon="Cancel">
                                <Listeners>
                                    <Click Fn="ClostWin" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Content>
                    <ext:ColumnLayout ID="ColumnLayout2" runat="server">
                        <Columns>
                            <ext:LayoutColumn ColumnWidth="1">
                                <ext:Panel ID="Panel7" runat="server" Border="false">
                                    <Content>
                                        <ext:FormLayout ID="FormLayout2" runat="server" LabelWidth="100">
                                            <Anchors>
                                                <ext:Anchor Horizontal="100%">
                                                    <ext:TextField ID="exttxtf_Use_ID" LabelStyle=" text-align:right; " runat="server"
                                                        FieldLabel="用途编号" Visible="false">
                                                    </ext:TextField>
                                                </ext:Anchor>
                                                <ext:Anchor Horizontal="100%">
                                                    <ext:TextField ID="exttxtf_inner_no" LabelStyle=" text-align:right; " runat="server"
                                                        FieldLabel="内部编码" Visible="false">
                                                    </ext:TextField>
                                                </ext:Anchor>
                                                <ext:Anchor Horizontal="100%">
                                                    <ext:TextField ID="exttxtf_Use_NAME" LabelStyle=" text-align:right; " runat="server"
                                                        FieldLabel="用途名称" >
                                                         <DirectEvents>
                                                            <Blur OnEvent="GetPY">
                                                            </Blur>
                                                        </DirectEvents>
                                                    </ext:TextField>
                                                </ext:Anchor>
                                                 <ext:Anchor Horizontal="100%">
                                                    <ext:TextField ID="exttxtf_Use_pym" LabelStyle=" text-align:right; " runat="server"
                                                        FieldLabel="拼音码" >
                                                    </ext:TextField>
                                                </ext:Anchor>
                                                <ext:Anchor Horizontal="100%">
                                                    <ext:TextField ID="exttxtf_parent_id" LabelStyle=" text-align:right; " runat="server"
                                                        FieldLabel="上级用途" ReadOnly="true" StyleSpec="background:#fffbf0;">
                                                    </ext:TextField>
                                                </ext:Anchor>
                                                <ext:Anchor Horizontal="100%">
                                                    <ext:TextArea ID="exttxtf_remark" LabelStyle=" text-align:right; " runat="server"
                                                        FieldLabel="备注">
                                                    </ext:TextArea>
                                                </ext:Anchor>
                                            </Anchors>
                                        </ext:FormLayout>
                                    </Content>
                                </ext:Panel>
                            </ext:LayoutColumn>
                        </Columns>
                    </ext:ColumnLayout>
                </Content>
            </ext:Panel>
        </Content>
    </ext:Window>
    <ext:Hidden ID="hid_tabid" runat="server" />
    <ext:Hidden ID="extHid_coboDeptId" runat="server" />
    <ext:Hidden ID="extHid_Obj_ID" runat="server" />
    </form>
</body>
</html>